<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin_Controller extends Page_Controller{
    function Admin_Controller(){
        parent::Page_Controller();
        $CI = &get_instance();
        //if($CI->uri->segment(2)!='home.login'){
        $CI->load->module_library('users.auth');
        // If not logged in
        if(!$CI->auth->is_logged()){
            $CI->session->set_userdata('redirect_page', $CI->uri->uri_string());
            redirect('admin/home.login');
        }else{
            if(strtolower(get_class($this))=='home')
                return;
            // Logged in
            //If is SuperAdmin
            if($CI->auth->is_superadmin()){
                // Supper Admin cannot go to Admin Area
                if(empty($this->access_supperadmin))
                    $CI->auth->logout(FALSE);
            }else{
            // If Admin
                // Admin cannot goto Supper Admin Area
                if(!empty($this->access_supperadmin))
                    $CI->auth->logout(TRUE);
            }
        }
        //}
    }
}
?>